home *** CD-ROM | disk | FTP | other *** search
- ;"db2html.scm" Convert relational database to hyperlinked pages.
-
- (require 'html-form)
- (require 'net-clients)
-
- ;;@subsection HTML databases
-
- ;;@code{(require 'db->html)}
-
- ;;@body @1 must be a relational database. @2 must be #f or a
- ;;non-empty string naming an existing sub-directory of the current
- ;;directory.
- ;;
- ;;@0 creates an html page for each table in the database @1 in the
- ;;sub-directory named @2, or the current directory if @2 is #f. The
- ;;top level page with the catalog of tables (captioned @4) is written
- ;;to a file named @3.
- (define (db->files db dir index-filename caption)
- (call-with-output-file (in-vicinity (if dir (sub-vicinity "" dir) "")
- index-filename)
- (lambda (port)
- (fluid-let ((*html:output-port* port))
- (catalog->page db caption))))
- ((((db 'open-table) '*catalog-data* #f) 'for-each-row)
- (lambda (row)
- (call-with-output-file
- (in-vicinity (sub-vicinity "" dir) (table-name->filename (car row)))
- (lambda (port)
- (fluid-let ((*html:output-port* port))
- (table->page db (car row) index-filename)))))))
-
- ;;@args db dir index-filename
- ;;@args db dir
- ;;@1 must be a relational database. @2 must be a non-empty
- ;;string naming an existing sub-directory of the current directory or
- ;;one to be created. The optional string @3 names the filename of the
- ;;top page, which defaults to @file{index.html}.
- ;;
- ;;@0 creates sub-directory @2 if neccessary, and calls
- ;;@code{(db->files @1 @2 @3 @2)}. The @samp{file:} URL of @3 is
- ;;returned.
- (define (db->directory db dir . index-filename)
- (set! index-filename (if (null? index-filename)
- "index.html"
- (car index-filename)))
- (if (symbol? dir) (set! dir (symbol->string dir)))
- (if (not (file-exists? dir)) (make-directory dir))
- (db->files db dir index-filename dir)
- (path->url (in-vicinity (sub-vicinity "" dir) index-filename)))
-
- ;;@args db dir index-filename
- ;;@args db dir
- ;;@0 is just like @code{db->directory}, but calls
- ;;@code{browse-url-netscape} with the url for the top page after the
- ;;pages are created.
- (define (db->netscape . args)
- (browse-url-netscape (apply db->directory args)))
-